﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;


using WCFMINERP.Contracts.DataContracts;
using System.Net;


namespace WCFMINERP.Update
{
    public class ShopInfoConfig
    {
        public static ShopInfo _shopInfo;
        
        public static void InitParameters()
        {
            ShopParametersInfo shopparasInfo = XMLOperator.GetShopParameters(Application.StartupPath + "\\ShopParameters.xml");
            WCFMINERP.ContextPropagation.ApplicationContext.Current.Shopid = _shopInfo.ShopId;
            WCFMINERP.ContextPropagation.ApplicationContext.Current.ShopName = _shopInfo.shopName;
            WCFMINERP.ContextPropagation.ApplicationContext.Current.ClientVersion = shopparasInfo.ClientVersion;//本地xml文件中的客户端版本
            WCFMINERP.ContextPropagation.ApplicationContext.Current.IsOnline = true;
            WCFMINERP.ContextPropagation.ApplicationContext.Current.MachineName = _shopInfo.MachineName;//机器名
            WCFMINERP.ContextPropagation.ApplicationContext.Current.ProductVersion = shopparasInfo.ProductVersion;//本地xml文件中的产品版本
            WCFMINERP.ContextPropagation.ApplicationContext.Current.SHACODE = _shopInfo.SHACODE;//授权码
            WCFMINERP.ContextPropagation.ApplicationContext.Current.UName = _shopInfo.FtpLoginName;
            WCFMINERP.ContextPropagation.ApplicationContext.Current.Upwd = _shopInfo.FtpLoginPWD;
        }

        public static void SaveParatoToxmlFile(ShopParametersInfo shopParas)
        {
            string xmlPath = Application.StartupPath + "\\ShopParameters.xml";
            XMLOperator.CreateShopParametersXml(xmlPath);
           // XMLOperator.UpdateNodesValue(@"ShopParameters/ShopName", xmlPath, shopParas.ShopName);
            //XMLOperator.UpdateNodesValue(@"ShopParameters/IsOnline", xmlPath, shopParas.IsOnline.ToString());
            XMLOperator.UpdateNodesValue(@"ShopParameters/ClientVersion",xmlPath,shopParas.ClientVersion);
            //XMLOperator.UpdateNodesValue(@"ShopParameters/MachineName", xmlPath, shopParas.MachineName);
            XMLOperator.UpdateNodesValue(@"ShopParameters/ProductVersion", xmlPath, shopParas.ProductVersion);
            //XMLOperator.UpdateNodesValue(@"ShopParameters/SHACODE", xmlPath, shopParas.SHACODE);
            //XMLOperator.UpdateNodesValue(@"ShopParameters/UName", xmlPath, shopParas.UName);
            //XMLOperator.UpdateNodesValue(@"ShopParameters/Upwd", xmlPath, shopParas.Upwd);

        }


    }
}
